import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import zhangHaoService from '/@/api/cn/core/cs/zhangHaoService'

import type { ZhangHao } from '/@/model/cn/core/cs/eo/ZhangHao'
import type { ZhangHaoQO } from '/@/model/cn/core/cs/qo/ZhangHaoQO'
import type { ZhangHaoVO } from '/@/model/cn/core/cs/vo/ZhangHaoVO'

interface ZhangHaoState {
}

export const useZhangHaoStore = defineStore({
  id: 'zhangHao',
  state: (): ZhangHaoState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.save(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.saveBatch(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.update(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.updateBatch(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.remove(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ZhangHao>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.removeBatch(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ZhangHaoQO>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.count(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ZhangHaoQO>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.pk(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ZhangHaoQO>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.query(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ZhangHaoQO>): Promise<Res<ZhangHao>> {
      return new Promise<Res<ZhangHao>>((resolve, reject) => {
        zhangHaoService.paging(param).then((res: AxiosResponse<Res<ZhangHao>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ZhangHaoQO>): Promise<Res<ZhangHaoVO>> {
      return new Promise<Res<ZhangHaoVO>>((resolve, reject) => {
        zhangHaoService.countVo(param).then((res: AxiosResponse<Res<ZhangHaoVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ZhangHaoQO>): Promise<Res<ZhangHaoVO>> {
      return new Promise<Res<ZhangHaoVO>>((resolve, reject) => {
        zhangHaoService.pkVo(param).then((res: AxiosResponse<Res<ZhangHaoVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ZhangHaoQO>): Promise<Res<ZhangHaoVO>> {
      return new Promise<Res<ZhangHaoVO>>((resolve, reject) => {
        zhangHaoService.queryVo(param).then((res: AxiosResponse<Res<ZhangHaoVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ZhangHaoQO>): Promise<Res<ZhangHaoVO>> {
      return new Promise<Res<ZhangHaoVO>>((resolve, reject) => {
        zhangHaoService.pagingVo(param).then((res: AxiosResponse<Res<ZhangHaoVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useZhangHaoStoreWithout() {
  return useZhangHaoStore(store)
}
